package com.xdxc.controller;

import cn.hutool.db.PageResult;
import com.xdxc.model.form.ExamProgressForm;
import com.xdxc.model.query.ExamProgressQuery;
import com.xdxc.model.vo.ExamProgressVO;
import com.xdxc.response.Result;
import com.xdxc.service.serviceinterface.ScoringTaskService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Controller
@RequestMapping("/v1/examProgress")
public class ScoringTaskController {

    @Autowired
    private ScoringTaskService scoringTaskService;

    @GetMapping("/page")
    public PageResult<ExamProgressVO> getExamProgressPage(ExamProgressQuery queryParams ) {
        return null;
    }

    @PostMapping
    public Result<Void> saveExamProgress(@RequestBody @Valid ExamProgressForm formData ) {
        boolean result = scoringTaskService.saveExamProgress(formData);
        return null;
    }

    @GetMapping("/{id}/form")
    public Result<ExamProgressForm> getExamProgressForm(
           @PathVariable Long id
    ) {
        ExamProgressForm formData = scoringTaskService.getExamProgressFormData(id);
        return Result.success(formData);
    }

    @PutMapping(value = "/{id}")
    public Result<Void> updateExamProgress(
            @Parameter(description = "mnvcvbnID") @PathVariable Long id,
            @RequestBody @Validated ExamProgressForm formData
    ) {
        boolean result = scoringTaskService.updateExamProgress(id, formData);
        return null;
    }

    @Operation(summary = "删除mnvcvbn")
    @DeleteMapping("/{ids}")
    @PreAuthorize("@ss.hasPerm('system:examProgress:delete')")
    public Result<Void> deleteExamProgresss(
            @Parameter(description = "mnvcvbnID，多个以英文逗号(,)分割") @PathVariable String ids
    ) {
        boolean result = scoringTaskService.deleteExamProgresss(ids);
        return null;
    }
    @PostMapping("/getExamProgress")
    public Result<ExamProgressForm> getExamProgress(
            @RequestBody @Valid ExamProgressForm examProgressForm
    ) {
        ExamProgressForm formData = scoringTaskService.getExamProgressFormData(examProgressForm);
        return Result.success(formData);
    }
}
